package week08.xa;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import week08.horizontal.UserOrderRepository;

/**
 * @author edward
 * @since 2021-08-14
 */
public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext("week08.horizontal");
        UserOrderRepository repo = context.getBean("userOrderRepository", UserOrderRepository.class);

        xaInserts(repo);
        xaDeletes(repo);
    }

    private static void xaInserts(UserOrderRepository repo) {
        for (int i=10000; i < 20000; i++) {
            repo.xaInsert(i, "Result-" + i);
        }
    }

    private static void xaDeletes(UserOrderRepository repo) {
        for (int i=10000; i < 20000; i++) {
            repo.xaDeleteByUser(i);
        }
    }
}
